<?php
/**
 * Short Description  
 *
 * Long Description 
 *
 * @category   
 * @package    
 * @subpackage 
 * @copyright 
 * @author     Sandeep Manne<sandeep.manne@costrategix.com>
 */

class Core_Payment
{
	private $_gateway = null;
	private $_type    = null;
	
	public function initalize($gateway, $type)
	{
		if ($gateway && $this->_intializeGateway($gateway) 
		             && $this->_gateway->isValidPaymentType($type)) {
			$this->_gateway->setType($type);
		}
	}
	
	private function _intializeGateway($gateway)
	{
		$gateway = ucfirst($gateway);
		try {
			require_once "Payment/".$gateway.".php";
			$this->_gateway =  new $gateway();
		} catch (Exception $e) {
			throw new Exception("Error initalizing payment gateway ". $e->getMessage());
		}
		return true;
	}
	
	public function authorize($paymentDetails)
	{
		$this->_gateway->authorize($paymentDetails);
	}
}